home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 48 / Amiga Format CD48 (1999-12-13)(Future Publishing)(GB)(Track 1 of 2)[!][issue 2000-01].iso / -serious- / programming / mui / mcc_popph / developer / c / examples / popph_demo.c
C/C++ Source or Header  |  1999-11-08  |  6KB  |  202 lines

  1.  
  2. /*
  3. ** $Id: popph_demo.c,v 1.1 1999/10/13 21:51:15 carlos Exp $
  4. */
  5.  
  6. /// Includes
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include <stdlib.h>
  12. #include <exec/types.h>
  13. #include <libraries/mui.h>
  14. #include <libraries/asl.h>
  15. #include <proto/exec.h>
  16. #include <proto/muimaster.h>
  17.  
  18. #include "Popplaceholder_mcc.h"
  19.  
  20. LONG __stack = 18192;
  21.  
  22. #define SAVEDS __saveds
  23. #define ASM __asm
  24. #define REG(x) register __ ## x
  25.  
  26. //|
  27.  
  28. char VER[] = "$VER: PopplaceholderDemo 0.6 (06.11.99)";
  29.  
  30. /// CleanUp
  31. void CleanUp(void)
  32. {
  33.    if(MUIMasterBase)   {CloseLibrary(MUIMasterBase); MUIMasterBase = NULL; }
  34. }
  35. //|
  36. /// xget
  37. ULONG xget( Object *obj, int attr)
  38. {
  39. ULONG val;
  40.  
  41.         get( obj, attr, &val);
  42.         return( val );
  43. }
  44. //|
  45.  
  46. /// Main
  47.  
  48. static const char *PP_Table[] =
  49. {
  50.     "%s|normal",
  51.     "%g|highlight",
  52.     "%x|3-dimensional",
  53.     "%w|4-dimensional",
  54.     "Tag|Description",
  55.     "WWW|World Wide Web",
  56.     NULL
  57. };
  58.  
  59. static const char *PP_Table_Single[] =
  60. {
  61.         "something 1",
  62.         "something 2",
  63.         "something 3",
  64.         NULL
  65. };
  66.  
  67. struct  Library *MUIMasterBase  = NULL;
  68.  
  69. #define TextObj(a) TextObject, MUIA_Text_Contents, (a), MUIA_Font, MUIV_Font_Tiny, End
  70.  
  71.  
  72. int main(void)
  73. {
  74.  
  75. APTR app, window, pph;
  76.  
  77.  
  78.    if( !(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)) )
  79.        {
  80.        printf("Can't open %s v%ld\n", MUIMASTER_NAME, MUIMASTER_VMIN);
  81.        CleanUp();
  82.        return(EXIT_FAILURE);
  83.        }
  84.  
  85.    app = ApplicationObject,
  86.             MUIA_Application_Title      , "Popplaceholder Demo",
  87. //            MUIA_Application_Version    , VERSTAG,
  88.             MUIA_Application_Copyright  , "©1999 Marcin Orlowski <carlos@amiga.com.pl>",
  89.             MUIA_Application_Author     , "Marcin Orlowski",
  90.             MUIA_Application_Base       , "POPPLACEHOLDERDEMO",
  91.             MUIA_Application_Window     ,
  92.                window = WindowObject,
  93.                         MUIA_Window_ID, 0,
  94.                         MUIA_Window_Title, "Popplaceholder demo",
  95.                         WindowContents,
  96.                               VGroup,
  97.                               Child, TextObj("\033cOrdinary object"),
  98.                               Child, pph = PopphObject,
  99.                                      MUIA_Popph_Array      , PP_Table,
  100.                                      MUIA_Popph_Contents   , "Something",
  101. //                                     MUIA_Popph_ReplaceMode, TRUE,
  102.                                      End,
  103.  
  104.  
  105.                               Child, TextObj("\033cAnd PopAsl alike"),
  106.                               Child, PopphObject,
  107.                                      MUIA_Popph_Contents   , "300 chars limit",
  108.                                      MUIA_Popph_Array      , PP_Table,
  109.                                      MUIA_Popph_PopAsl     , TRUE,
  110.                                      MUIA_Popph_Contents   , "RAM:",
  111.                                      ASLFR_DoSaveMode      , TRUE,
  112.                                      End,
  113.  
  114.  
  115.                               Child, TextObj("\033cAnother PopAsl (drawers only)"),
  116.                               Child, PopphObject,
  117.                                      MUIA_Popph_Array      , PP_Table,
  118.                                      MUIA_Popph_PopAsl     , TRUE,
  119.                                      MUIA_Popph_Contents   , "SYS:",
  120.                                      ASLFR_DrawersOnly     , TRUE,
  121.                                      End,
  122.  
  123.  
  124.                               Child, TextObj("\033cAlways 'classic' string (we Avoid others)"),
  125.                               Child, PopphObject,
  126.                                      MUIA_Popph_Array      , PP_Table,
  127.                                      MUIA_Popph_Avoid      , MUIV_Popph_Avoid_Textinput | MUIV_Popph_Avoid_Betterstring,
  128.                                      End,
  129.  
  130. /*
  131.                               Child, TextObject, MUIA_Text_Contents, "\033cLet's override the string object", End,
  132.                               Child, PopphObject,
  133.                                      MUIA_Popph_Array       , PP_Table,
  134.                                      MUIA_Popph_StringObject, StringObject, End,
  135.                                      End,
  136. */
  137.  
  138.                               Child, TextObj("\033cList with column title"),
  139.                               Child, PopphObject,
  140.                                      MUIA_Popph_Array      , PP_Table,
  141.                                      MUIA_Popph_Title      , "\033bCol1|\033u\033iCol2",
  142.                                      MUIA_Popph_Contents   , "Nothing ;-)",
  143.                                      End,
  144.  
  145.                               Child, TextObj("\033cSingle column..."),
  146.                               Child, PopphObject,
  147.                                      MUIA_Popph_Array       , PP_Table_Single,
  148.                                                                          MUIA_Popph_SingleColumn, TRUE,
  149.                                      MUIA_Popph_Title       , "\033bTitle",
  150.                                      MUIA_Popph_Contents    , "... with replace mode",
  151.                                      MUIA_Popph_ReplaceMode , TRUE,
  152.                                      End,
  153.  
  154.  
  155.  
  156.                               End,
  157.                         End,
  158.  
  159.                  End;
  160.  
  161.  
  162.  
  163.       if(app)
  164.         {
  165.         DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  166.  
  167.  
  168.         set(window,MUIA_Window_Open,TRUE);
  169.  
  170.         if( xget(window, MUIA_Window_Open) )
  171.            {
  172.            ULONG sigs = 0;
  173.  
  174.            while(DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  175.              {
  176.              if(sigs)
  177.                {
  178.                sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  179.                if(sigs & SIGBREAKF_CTRL_C) break;
  180.                }
  181.              }
  182.            }
  183.         else
  184.            {
  185.            printf("Can't open window!\n");
  186.            }
  187.  
  188. //              printf( "Result string: '%s'\n", xget(pph, MUIA_Popph_Contents) );
  189.  
  190.         MUI_DisposeObject(app);
  191.         }
  192.       else
  193.         {
  194.         printf("Can't create application object\n");
  195.         DisplayBeep(NULL);
  196.         }
  197.  
  198.    CleanUp();
  199.    return(EXIT_SUCCESS);
  200. }
  201. //|
  202.